<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class Person {
        race = (() => {
          console.log('公共字段求值')
          return '人类'
        })()
        constructor(name, age) {
          this.name = name
          this.age = age
          console.log('运行构造函数')
        }
        say() {
          console.log(`${this.name}的年龄是${this.age}`)
        }
      }
      class Male extends Person {
        constructor(name, age, height) {
          super(name, age)
          this.height = height
        }
        say() {
          super.say()
          console.log(`${this.name}的身高是${this.height}`)
        }
      }
      const p1 = new Person('张三', 18)
      const m1 = new Male('李四', 20, 180)
      console.log(p1)
      m1.say()
    </script>
  </body>
</html>
